/**
 * @ Author: luoqi
 * @ Create Time: 2024-04-17 18:02
 * @ Modified by: luoqi
 * @ Modified time: 2025-07-06 23:58
 * @ Description:
 */

#ifndef _QBOOT_H
#define _QBOOT_H

#include <stdint.h>
#include <stddef.h>
#include "iap_cfg.h"

typedef int (*IapSend)(const void *buf, size_t sz);
typedef int (*IapRecv)(void *buf, size_t sz, size_t timeout_ms);
typedef int (*IapMemWrite)(size_t addr, const void *data, size_t sz);
typedef int (*IapMemErase)(size_t addr, size_t sz);

typedef struct {
    IapSend send;
    IapRecv recv;
    IapMemWrite mem_write;
    IapMemErase mem_erase;
} IapObj;

int iap_init(IapSend send, IapRecv recv, IapMemWrite mem_write, IapMemErase mem_erase);

int iap_exec();

int iap_jump(size_t addr);

#endif
